<?php error_reporting(0) ;
ini_set("display_errors", 0 );
?>
<script type="text/javascript" src="<?php echo base_url() . 'assets/js/validate.js'?>"></script>
<script type="text/javascript" src="<?php echo base_url() . 'assets/js/calendario.js'?>"></script>
<script type="text/javascript">
    
	
</script>
<div align="center">
        <div align="center" id="div_principal">
          <form id="formListaAluno">
<table width="740" align="center">
                    <tr>
                        <td width="146" align="right">Matr&iacute;cula:</td>
                        <td width="105" align="left"><input type="text" size="10" id="matricula" />
                        <div class="suggestionsBox" id="suggestions" style="display: none;">
                            <img src="<?php echo base_url() . 'assets/images/upArrow.png' ?>" style="position: relative; top: -12px; left: 30px;" alt="upArrow" />
                            <div class="suggestionList" id="autoSuggestionsList"></div>
                        </div>                        </td>
                        
                      <td width="58" align="right">Nome:</td>
                      <td width="271" align="left"><input type="text" size="40" id="nome"/></td>
                      <td width="136" align="left">
                      	<a href="#" id="btnLocalizarAluno"  onclick="localizaAluno()">
                        	<img src="<?php echo base_url() . 'assets/images/ico_view.png' ?>" />
                        </a>
                      </td>
                    </tr>
                </table>
            </form>
          <table width="740">
<tr>
                    <td align="left" id="addAluno">
          <div style="font-size: 12px; font-weight: bold;">
                            <a href="#">
                                <img alt="" src="<?php echo base_url() . 'assets/images/add_aluno.jpg' ?>" border="0" title="Novo Aluno" onclick="addAluno()" width="30" height="30"/>
                            </a>Novo Aluno
                        </div>
                    </td>
        <td ></td>
              </tr>
            </table>
          <br />
        </div><br /></div>
        <div id="listaAluno" ></div>
        <br /><br /><br />
        

<script>
function lookup(matricula) {
        
        if(matricula.length == 0) {
            // Hide the suggestion box.
            $('#suggestions').hide();
        } else {
            
            jQuery.ajax( {
                type: "POST",
                url: '?c=c_aluno&m=buscaAutoComplete',
                cache: false,
                data: {queryString:matricula},
                beforeSend: function (){
                    $('#div_body').addClass("div_carregando");
                },
                complete:  function(){
                    $('#div_body').removeClass("div_carregando");
                },
                success: function(data){
                    if(data.length >0) {
                        //$('#suggestions').show();
                        $('#div_body').html(data);
                    }
                }
            });

        }
    } 
    
    function fill(thisValue) {
        $('#matricula').val(thisValue);
        setTimeout("$('#suggestions').hide();", 200);
    }  
    
    
    function addAluno(){

                jQuery.ajax( {
                    type: "POST",
                    url: '?c=c_aluno&m=addAluno',
                    cache: false,
                    beforeSend: function (){
                        $('#div_body').addClass("div_carregando");
                    },
                    complete:  function(){
                        $('#div_body').removeClass("div_carregando");

                    },
                    success: function(data){
                        $("#div_body").html(data);
                    }
                });


    }
    
    function showAluno(alunoId){

            jQuery.ajax( {
                type: "POST",
                url: '?c=c_aluno&m=listarAluno',
                cache: false,
                data: {alunoId:alunoId},
                beforeSend: function (){
                    $('#div_body').addClass("div_carregando");
                },
                complete:  function(){
                    $('#div_body').removeClass("div_carregando");

                },
                success: function(data){
                    $("#div_body").html(data);
                }
            });

    }
        
    function localizaAluno(){
        var matricula = jQuery('input[id="matricula"]').val();
        var nome = jQuery('input[id="nome"]').val();

        if(!matricula && !nome){
            alert('Por favor, informe no minimo um criterio para pesquisa.');

        } else {
            jQuery.ajax( {
                type: "POST",
                url: '?c=c_aluno&m=listarAlunoDataTable',
                cache: false,
                data: {matricula:matricula,nome:nome},
                beforeSend: function (){
                    $('#div_body').addClass("div_carregando");
                },
                complete:  function(){
                    $('#div_body').removeClass("div_carregando");

                },
                success: function(data){
                    $("#div_body").html(data);
                }
            });


        }

    }

    function detalharResponsavel(id){

        jQuery.ajax( {
            type: "POST",
            url: '?c=c_responsavel&m=detalharResponsavel',
            cache: false,
            data: {id:id},

            beforeSend: function (){
                $('#div_body').addClass("div_carregando");
            },
            complete:  function(){
                    $('#div_body').removeClass("div_carregando");
                   
            },
            success: function(data){
//                $("#formPcpResponsavel").html(data);
                jQuery.facebox(data);
            }
        });
    }
    
</script>